//
// Created by 吴浩 on 2025/8/4.
//
#include<string>
class Solution {
public:
    string convertToBase7(int num) {
        if (num == 0) return "0";
        bool flag = false;
        if (num < 0)
        {
            flag = true;
            num = -num;
        }

        string result;
        while(num != 0)
        {
            int res=num%7;
            result+=to_string(res);
            num=num/7;
        }

        reverse(result.begin(), result.end());
        return flag ? "-" + result : result;


    }
};